package interview;

import java.util.Scanner;
import java.util.Stack;

public class zuiyou01 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String max = "9223372036854775807";
        Stack<Character> stack = new Stack<>();
        char[] arr = s.toCharArray();
        boolean flag = true;// 判断是否为负数
        long res = 0;// 最后的结果
        for (int i = 0; i < arr.length; i++){
            if (arr[i] >= 'a' && arr[i] <= 'z' || arr[i] >= '0' && arr[i] <= '9'){
                stack.add(arr[i]);
            }else if (i == 0 && arr[i] == '-'){
                flag = false;
            }else {
                System.out.println(0);
                return;
            }
        }
        int index = 0;// 36位的位数
        while (!stack.isEmpty()){
            if (stack.peek() >= 'a' && stack.peek() <= 'z'){
               int num = stack.pop() - 'a' + 10;
               res += num * Math.pow(36,index);
               if (res >= Long.parseLong(max)){
                   System.out.println(max);
                   return;
               }
            }else{
                int num = stack.pop() - '0';
                res += num * Math.pow(36,index);
                if (res >= Long.parseLong(max)){
                    System.out.println(max);
                    return;
                }
            }
            index++;
        }
        if (flag) {
            System.out.println(res);
        }else {
            if (-res < -Long.parseLong(max)) {
                System.out.println("-"+max);
            } else {
                System.out.println(-res);
            }
        }
    }
}
class Test{
    public static void main(String[] args) {
        System.out.println('y' - 'a');
    }
}